package cn.lili.modules.store.entity.vos;

import cn.hutool.core.date.DateUtil;
import cn.lili.common.utils.StringUtils;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.store.entity.enums.StoreStatusEnum;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

@Data
public class MarketSearchParams extends PageVO implements Serializable {
    private static final long serialVersionUID = 6916054330764833369L;


    @ApiModelProperty(value = "市场名称")
    private String marketName;
    /**
     * @see StoreStatusEnum
     */
    @ApiModelProperty(value = "市场状态")
    private String marketDisable;


    public <T> QueryWrapper<T> queryWrapper() {
        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(marketName)) {
            queryWrapper.like("market_name", marketName);
        }
        if (StringUtils.isNotEmpty(marketDisable)) {
            queryWrapper.eq("market_disable", marketDisable);
        } else {
            queryWrapper.and(Wrapper -> Wrapper.eq("market_disable", StoreStatusEnum.OPEN.name()).or().eq("market_disable", StoreStatusEnum.CLOSED.name()));
        }
        return queryWrapper;
    }
}

